home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS01.ADF / C / setlace.c < prev    next >
C/C++ Source or Header  |  1985-11-15  |  6KB  |  170 lines

  1. /*
  2. Path: puff!uwvax!seismo!lll-crg!ucdavis!ucbvax
  3.         !decvax!decwrl!pyramid!amiga!bobp
  4. From: bobp@amiga.UUCP (Robert S. Pariseau)
  5. Subject: SetLace program SOURCE
  6. Date: 4 Nov 85 20:04:15 GMT
  7. Organization: Commodore-Amiga Inc., 983 University Ave #D, Los Gatos CA 95030
  8.     
  9. The following program may be used to experiment with the appearance of your 
  10. Amiga text and graphics when interlace is turned on.  For non-interlaced 
  11. "screens", the effect will be to line-double each raster line.  The visual 
  12. result is that the black "gaps" between raster lines are dramatically reduced 
  13. (the pixels appear to have become somewhat taller).  For text, this yields a 
  14. "fuller" character that many people find more pleasing.
  15.  
  16. Because interlace is turned on, many people will notice "flicker" in the 
  17. image.  The physiology of flicker perception is pretty well understood.  The 
  18. eye's ability to see flicker increases as the overall luminence (display plus 
  19. room light) goes up and as the contrast between adjacent horizontal lines 
  20. goes up.  Flicker can be dramatically reduced -- even to the point that you 
  21. may not see it at all -- by adjusting the color, contrast, and brightness of 
  22. your display.
  23.  
  24. Many folks have turned up the contrast and brightness controls of their 
  25. display to get a more striking effect with the Amiga graphics.  I would 
  26. suggest you start out your experiment by resetting those controls to their 
  27. center position.  I have found that I get a pleasing image by adjusting the 
  28. Workbench colors in Preferences such that the "white" color is a light grey 
  29. (4-6 clicks in each of R, G, and B to the left of the indicator triangle) and 
  30. the "blue" color is somewhat darker than default (2 clicks to the left of G 
  31. and B).  I also reduce the "orange" for balance.
  32.  
  33. As with any display, you may find it better to use incandescent room 
  34. lighting.  Flourescent lights also flicker and can "beat" with the display 
  35. giving your eyes a real workout.
  36.  
  37. If you like the results, I'd suggest you stick a SetLace command in your 
  38. startup script (s/startup-sequence) just prior to the LoadWB command.
  39.  
  40. Program Notes:  The program will compile cleanly using the standard V1.0 
  41. Lattice C release stuff.  The Make script in the C exmples directory will do 
  42. all the work.
  43.  
  44. The rather large list of include files is necessary to keep Lattice C from 
  45. warning about undefined structures.  The warnings refer to structures 
  46. referenced as the target of pointers in OTHER structure definitions.  We're 
  47. working on getting the C to be not quite so picky, so that you can limit your 
  48. includes to those definitions you actually use in expressions.  These 
  49. warnings can be safely ignored, but they don't look clean.
  50.  
  51. The program is designed to be run from the CLI only.  The command
  52.   SetLace
  53. will turn on the forced interlace mode.  The command
  54.   SetLace off
  55. will turn it off again.
  56.  
  57. Note that forcing interlace does not change either the amount of memory or 
  58. bus bandwidth used by text or graphics programs.  The same bitmap is just 
  59. repeated one half raster line down by the hardware in the odd frame.
  60. */
  61.  
  62. /************************************************************************
  63.  *  SetLace -- Program to force the Amiga into interlaced display
  64.  *             regardless of the interlace status of the currently
  65.  *             active Screens (ViewPorts).  Run from the CLI (only).
  66.  *
  67.  *             1> SetLace        -- Set forced Interlace mode
  68.  *             1> SetLace off    -- Clear forced Interlace mode
  69.  *
  70.  *   Bob Pariseau -- November 2, 1985
  71.  *
  72.  ************************************************************************/
  73.  
  74. #include <exec/types.h>
  75. #include <exec/tasks.h>
  76. #include <exec/libraries.h>
  77. #include <graphics/copper.h>
  78. #include <graphics/display.h>
  79. #include <graphics/gfxbase.h>
  80. #include <graphics/text.h>
  81. #include <graphics/view.h>
  82. #include <hardware/blit.h>
  83. #include <intuition/intuitionbase.h>
  84.  
  85. struct GfxBase *GfxBase;
  86. struct IntuitionBase *IntuitionBase;
  87.  
  88. main(argc, argv)
  89.   int argc;
  90.   char  *argv[];
  91. {
  92.   BOOL TurnItOn;
  93.  
  94.   TurnItOn = TRUE;
  95.   if (argc > 1)
  96.     if (!strcmp(argv[1], "off")) TurnItOn = FALSE;
  97.  
  98.   GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0);
  99.   if (GfxBase == NULL) exit(1000);
  100.  
  101.   IntuitionBase = (struct IntuitionBase*)
  102.                   OpenLibrary("intuition.library", 0);
  103.   if (IntuitionBase == NULL)
  104.   {
  105.     CloseLibrary(GfxBase);
  106.     exit(2000);
  107.   }
  108.  
  109. /*  The system_bplcon0 value is ORed into all copper instructions that
  110.  *  change bplcon0 (one of the hardware bitplane control registers)
  111.  *  whenever copper lists are formed by the graphics library copper
  112.  *  list management routines.  This value provides a control context
  113.  *  for system display that overrides the normal control values usually
  114.  *  managed by Intuition.  In particular, Intuition manages the interlace
  115.  *  control in the View structure, so we have to do our control here
  116.  *  to give it some permanence.
  117.  */
  118.  
  119.   if (TurnItOn)
  120.     GfxBase->system_bplcon0 |=  INTERLACE;
  121.   else
  122.     GfxBase->system_bplcon0 &= !INTERLACE;
  123.  
  124. /*  Now we have to get all the copper lists rebuilt.  The easiest way
  125.  *  to do this is to have Intuition do it for us.  The correct way to
  126.  *  do THAT is to call RemakeDisplay() which is (sigh) broken in V1.0.
  127.  *  Therefore, we get by with the following hack.
  128.  */
  129.  
  130.   myRemakeDisplay(IntuitionBase);    /*??? RemakeDisplay();*/
  131.  
  132. /*  Be good, and clean up. */
  133.  
  134.   CloseLibrary(GfxBase);
  135.   CloseLibrary(IntuitionBase);
  136. }
  137.  
  138.  
  139.  
  140. myRemakeDisplay(IntuitionBase)
  141.   struct                            /* Cheat and use private knowledge */
  142.   {                                 /* of the initial portion of the   */
  143.     struct Library LibNode;         /* Intuition Base structure.       */
  144.     struct View ViewLord;
  145.   } *IntuitionBase;
  146. {
  147.   struct View *View;
  148.   struct ViewPort *ViewPort;
  149.  
  150.   Forbid();                         /* The V1.0 Intuition internal     */
  151.                                     /* locking protocol uses Forbid()  */
  152.                                     /* and Permit().  Under V1.1, this */
  153.                                     /* code could be unreliable if     */
  154.                                     /* another task was simultaneously */
  155.                                     /* manipulating the View.          */
  156.  
  157.   View = &IntuitionBase->ViewLord;
  158.  
  159.   ViewPort = View->ViewPort;
  160.   while (ViewPort)
  161.   {
  162.     MakeVPort(View, ViewPort);
  163.     ViewPort = ViewPort->Next;
  164.   }
  165.  
  166.   Permit();
  167.   RethinkDisplay();
  168. }
  169.  
  170.